﻿//======================================================
//==     (c)2013  OpenLayers.cn inc by 飞龙在天 v1.0  ==
//==          Forum:bbs.OpenLayers.cn                 ==
//==         Website:www.OpenLayers.cn                ==
//== 开源旗舰版见 淘宝: http://giscenter.taobao.com   ==
//======================================================
using System;
using System.Collections.Generic;
using System.Web;
namespace Common
{

    /// <summary>
    ///ProjectManage 的摘要说明
    /// </summary>
    public class ProjectManage
    {
        public ProjectManage()
        {
            //
            //TODO: 在此处添加构造函数逻辑
            //
        }
        public XY LatLonToMercator(double lon, double lat)
        {
            double x = lon * 20037508.34 / 180;
            double y = Math.Log(Math.Tan((90 + lat) * Math.PI / 360)) / (Math.PI / 180);
            y = y * 20037508.34 / 180;

            XY xy = new XY();
            xy.X = x;
            xy.Y = y;
            return xy;
        }
        public XY MercatorToLatLon(double xx, double yy)
        {
            double x = xx / 20037508.34 * 180;
            double y = yy / 20037508.34 * 180;
            y = 180 / Math.PI * (2 * Math.Atan(Math.Exp(y * Math.PI / 180)) - Math.PI / 2);
            XY xy = new XY();
            xy.X = x;
            xy.Y = y;
            return xy;
        }
    }
}